﻿//----------------------------------------------------------------------------------------------------
// A NodeInstance is the representation of a node in a level
//----------------------------------------------------------------------------------------------------

package HG.GameDataTypes
{
	import HG.Debug;
	
	import flash.geom.Point;
	
	import flash.net.registerClassAlias;
	

	public class NodeInstance
	{
		// Note only public variables get serialized!
		public var m_ID:Number;
		
		public var m_attachNodeID:Number; //- Only used in the editor.
		
		public var m_connections:Array;
		
		public var m_type:String;
		public var m_encryptionKey:Number;
		
		public var m_sentryTripChance:Array;
		
		//----------------------------------------------------------------------------------------------------
		public function NodeInstance()
		{
			registerClassAlias("NodeInstance", NodeInstance);
			
			m_connections = new Array();
			m_encryptionKey = 0;
			m_type = "";
			m_attachNodeID = -1;
			m_ID = -1;
			m_sentryTripChance = new Array();
		}
		
		//----------------------------------------------------------------------------------------------------
		public function AddTripChance(chance:Number, sentryNodeID:Number)
		{
			m_sentryTripChance[sentryNodeID] = chance;
		}
		
		//----------------------------------------------------------------------------------------------------
		public function GetTripChances():Array
		{
			return m_sentryTripChance;
		}
		
		//----------------------------------------------------------------------------------------------------
		public function SetID(ID:Number)
		{
			m_ID = ID;
		}
		
		//----------------------------------------------------------------------------------------------------
		public function GetID():Number
		{
			return m_ID;
		}
		
		//----------------------------------------------------------------------------------------------------
		public function SetType(type:String)
		{
			m_type = type;
		}
		
		//----------------------------------------------------------------------------------------------------
		public function GetType():String
		{
			return m_type;
		}
		
		//----------------------------------------------------------------------------------------------------
		public function SetEncryptionKey(key:Number)
		{
			m_encryptionKey = key;
		}
		
		//----------------------------------------------------------------------------------------------------
		public function GetEncryptionKey():Number
		{
			return m_encryptionKey;
		}
		
		//----------------------------------------------------------------------------------------------------
		public function SetConnections(connections:Array):void 
		{ 
			m_connections = connections;
		}
		
		//----------------------------------------------------------------------------------------------------
		public function GetConnections():Array 
		{ 
			return m_connections;
		}
		
		//----------------------------------------------------------------------------------------------------
		public function SetAttachID(ID:Number)
		{
			m_attachNodeID = ID;
		}
		
		//----------------------------------------------------------------------------------------------------
		public function GetAttachID():Number
		{
			return m_attachNodeID;
		}
		
		//----------------------------------------------------------------------------------------------------
		public function ToString():String
		{
			var output:String = "";
			output += "NodeInstance: " + m_ID + "\n";
			
			var index:Number = 0;
			var listLength:Number = m_connections.length;

			output += "\tConnections:"
			for (index = 0; index < listLength; ++index)
			{
				output += ", " + m_connections[index];
			}
			output += "\n";
	
			return output;
		}

	}

}